<?php

/**
 * This is the model class for table "quotation_request_detail".
 *
 * The followings are the available columns in table 'quotation_request_detail':
 * @property string $id
 * @property string $id_quotation_request
 * @property string $part_code
 * @property string $part_name
 * @property string $specs
 * @property string $nego_specs
 * @property string $qty
 * @property string $unit_code
 * @property string $lead_time
 * @property string $nego_delivery_date
 * @property double $unit_price
 * @property double $nego_unit_price
 * @property string $remark
 * @property string $nego_remark
 * @property string $nego_date
 * @property string $status
 * @property double $quotation_unit_price
 * @property string $supplier
 * @property string $currency
 * @property string $payment_term
 * @property string $purchase_requisition_number
 *
 * The followings are the available model relations:
 * @property QuotationRequest $idQuotationRequest
 */
class QuotationRequestDetail extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return QuotationRequestDetail the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'quotation_request_detail';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('unit_price, nego_unit_price, quotation_unit_price', 'numerical'),
			array('id_quotation_request, qty, lead_time, status, supplier', 'length', 'max'=>19),
			array('part_code, part_name, nego_specs, nego_remark, currency, payment_term, purchase_requisition_number', 'length', 'max'=>50),
			array('specs, unit_code, nego_delivery_date, remark, nego_date', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, id_quotation_request, part_code, part_name, specs, nego_specs, qty, unit_code, lead_time, nego_delivery_date, unit_price, nego_unit_price, remark, nego_remark, nego_date, status, quotation_unit_price, supplier, currency, payment_term, purchase_requisition_number', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'idQuotationRequest' => array(self::BELONGS_TO, 'QuotationRequest', 'id_quotation_request'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'id_quotation_request' => 'Id Quotation Request',
			'part_code' => 'Part Code',
			'part_name' => 'Part Name',
			'specs' => 'Specs',
			'nego_specs' => 'Nego Specs',
			'qty' => 'Qty',
			'unit_code' => 'Unit Code',
			'lead_time' => 'Lead Time',
			'nego_delivery_date' => 'Nego Delivery Date',
			'unit_price' => 'Unit Price',
			'nego_unit_price' => 'Nego Unit Price',
			'remark' => 'Remark',
			'nego_remark' => 'Nego Remark',
			'nego_date' => 'Nego Date',
			'status' => 'Status',
			'quotation_unit_price' => 'Quotation Unit Price',
			'supplier' => 'Supplier',
			'currency' => 'Currency',
			'payment_term' => 'Payment Term',
			'purchase_requisition_number' => 'Purchase Requisition Number',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('id_quotation_request',$this->id_quotation_request,true);
		$criteria->compare('part_code',$this->part_code,true);
		$criteria->compare('part_name',$this->part_name,true);
		$criteria->compare('specs',$this->specs,true);
		$criteria->compare('nego_specs',$this->nego_specs,true);
		$criteria->compare('qty',$this->qty,true);
		$criteria->compare('unit_code',$this->unit_code,true);
		$criteria->compare('lead_time',$this->lead_time,true);
		$criteria->compare('nego_delivery_date',$this->nego_delivery_date,true);
		$criteria->compare('unit_price',$this->unit_price);
		$criteria->compare('nego_unit_price',$this->nego_unit_price);
		$criteria->compare('remark',$this->remark,true);
		$criteria->compare('nego_remark',$this->nego_remark,true);
		$criteria->compare('nego_date',$this->nego_date,true);
		$criteria->compare('status',$this->status,true);
		$criteria->compare('quotation_unit_price',$this->quotation_unit_price);
		$criteria->compare('supplier',$this->supplier,true);
		$criteria->compare('currency',$this->currency,true);
		$criteria->compare('payment_term',$this->payment_term,true);
		$criteria->compare('purchase_requisition_number',$this->purchase_requisition_number,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}